package com.cashoutgaming.client.modules.home;

import com.cashoutgaming.client.common.SessionManager;
import com.cashoutgaming.client.gin.NameTokens;
import com.cashoutgaming.client.modules.shell.DesktopShellPresenter;
import com.cashoutgaming.client.widgets.recent_matches.RecentMatchesPresenter;
import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.HasUiHandlers;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.ContentSlot;
import com.gwtplatform.mvp.client.annotations.NameToken;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.annotations.Title;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.PlaceRequest;
import com.gwtplatform.mvp.client.proxy.ProxyPlace;
import com.gwtplatform.mvp.client.proxy.RevealContentHandler;

/**
 * This is the desktop mode presenter for the admin tool. This presenter will
 * contain all buisness logic to drive the admin tool. This presenter will
 * likely invoke other presenters / presenter widgets; e.g. customer
 * create/modify dialog
 */
public class HomePresenter extends Presenter<HomePresenter.MyView, HomePresenter.MyProxy> implements HomeUiHandlers {

	// the desktop shell will have multiple slots to contain other presenters
	// for now lets have 3 slots: a main content area, a left hand side tree
	// and a dialog slot
	@ContentSlot
	public static final Type<RevealContentHandler<?>> TYPE_TWITCH = new Type<RevealContentHandler<?>>();
	@ContentSlot
	public static final Type<RevealContentHandler<?>> TYPE_RECENT_MATCHES = new Type<RevealContentHandler<?>>();

	private RecentMatchesPresenter recentMatchesPresenter;

	@ProxyCodeSplit
	@NameToken(NameTokens.HOME)
	@Title("Desktop Application Shell")
	public interface MyProxy extends ProxyPlace<HomePresenter> {
	}

	public interface MyView extends View, HasUiHandlers<HomeUiHandlers> {
	}

	@Inject
	HomePresenter(EventBus eventBus, MyView view, MyProxy proxy, PlaceManager placeManager, SessionManager session,
			RecentMatchesPresenter recentMatchesPresenter) {
		super(eventBus, view, proxy, DesktopShellPresenter.TYPE_MAINPANEL);
		view.setUiHandlers(this);
		this.recentMatchesPresenter = recentMatchesPresenter;
	}

	@Override
	public void prepareFromRequest(PlaceRequest request) {
		super.prepareFromRequest(request);
	}

	@Override
	public void onBind() {
		setInSlot(TYPE_RECENT_MATCHES, recentMatchesPresenter);
	}
}
